//
//  ZSPopularViewController.m
//  zhushou
//
//  Created by Dejun Liu on 15/9/16.
//  Copyright (c) 2015年 cheney. All rights reserved.
//

#import "ZSPopularViewController.h"
#import "UIViewController+Extension.h"
#import "NetworkService+TianHai.h"
#import "MBProgressHUD.h"

@interface ZSPopularViewController ()

@property (weak, nonatomic) IBOutlet UIWebView *myWebView;

@end

@implementation ZSPopularViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"天嗨";
    [self getTianHiUrl];
}


- (void)getTianHiUrl
{
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    hud.removeFromSuperViewOnHide = YES;
    hud.labelText = @"玩命加载中...";
    [[NetworkService sharedInstance] th_postWithParams:nil action:@"TianHiNews" completion:^(NSDictionary *response, NSError *error) {
        [hud hide:YES];
        if (response) {
            DLog(@"%@",response);
            NSString *tianHiNews = response[@"respdata"][@"url"];
            if (tianHiNews) {
                [self webViewLoadTianHiNews:tianHiNews];
            }
        }
    }];
}

- (void)webViewLoadTianHiNews:(NSString *)url
{
    NSURLRequest *req = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
    [self.myWebView loadRequest:req];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
